//
//  ViewController.m
//  MyRobotApp
//
//  Created by 小肥羊 on 15/5/28.
//  Copyright (c) 2015年 小肥羊. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

#pragma mark - 惰性初始化
- (XFYRobot *)robot
{
    if (!_robot) {
        _robot = [[XFYRobot alloc] initRobot:kMyName];
    }
    return _robot;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    //添加机器人
    [self.view addSubview:self.robot.appearance];
}

- (void)dealloc
{
    [self.robot.memory.memory closeDB];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    [self.robot.appearance setFrame:self.assistRobotView.frame];
}

#pragma mark - 互动
- (IBAction)interaction:(UIButton *)sender {
    [self.robot receivingInformationWithMessage:self.interactionText.text];
}
- (IBAction)exitEdit:(id)sender {
    [self.view endEditing:YES];
}


@end
